﻿using System;
using System.Collections.Generic;
using BEX.Core.Exchange.MTGOXWebSocket.MTGoxResponseJsonTypes;
using Newtonsoft.Json.Linq;
using JsonCSharpClassGenerator;


namespace BEX.Core.Exchange.MTGOXWebSocket
{
    public class MTGoxResponse
    {
        public MTGoxResponse(string json)
            : this(JObject.Parse(json))
        {
        }

        private JObject __jobject;
        public MTGoxResponse(JObject obj)
        {
            this.__jobject = obj;
        }

        public string channel
        {
            get
            {
                return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "channel"));
            }
        }

        public string channel_name
        {
            get
            {
                return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "channel_name"));
            }
        }

        public string op
        {
            get
            {
                return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "op"));
            }
        }

        public string origin
        {
            get
            {
                return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "origin"));
            }
        }

        public string _private
        {
            get
            {
                return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "private"));
            }
        }

        [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
        private Ticker _ticker;
        public Ticker ticker
        {
            get
            {
                if (_ticker == null)
                {
                    _ticker = JsonClassHelper.ReadStronglyTypedObject<Ticker>(JsonClassHelper.GetJToken<JObject>(__jobject, "ticker"));
                }
                return _ticker;
            }
        }


        public string BaseCurrency
        {
            get
            {
                return this.ticker.item;
            }
        }

        public string CounterCurrency
        {
            get
            {
                return this.ticker.sell.currency;
            }
        }
    }
}
